package moon.core;

import java.io.Serializable;
import java.util.Collection;
import java.util.Iterator;

import moon.core.classdef.ClassDef;
import moon.core.classdef.NameSpace;
import moon.core.classdef.Type;

/**
 * Model.
 * 
 * @author <a href="mailto:rmartico@ubu.es">Ra&uacute;l Marticorena</a>
 * @since JavaMoon-2.0
 */
public interface Model extends Serializable {	
	
	/**
	 * Adds a name space.
	 * 
	 * @param nameSpace name
	 */
	public abstract void add(NameSpace nameSpace);

	/**
	 * Adds a type.
	 * 
	 * @param type type
	 */
	public abstract void add(Type type);

	/**
	 * Removes a type of the model.
	 * 
	 * @param type type
	 */
	public abstract void remove(Type type);
	
	
	/**
	 * Removes a classDef of the model.
	 * 
	 * @param classDef class
	 */
	public abstract void remove(ClassDef classDef);
	

	/**
	 * Gets the type by unique name.
	 * 
	 * @param uniqueName unique name
	 * @return type
	 */
	public abstract Type getType(Name uniqueName);

	/**
	 * Adds a class to the model.
	 * 
	 * @param classDef class
	 */
	public abstract void add(ClassDef classDef);

	/**
	 * Looks up the namespace in the model with this name.
	 * 
	 * @param uniqueName unique name
	 * @return true if exists a namespace with that name
	 */
	public abstract boolean hasNameSpace(Name uniqueName);

	/**
	 * Gets the name space associated to the name.
	 * 
	 * @param uniqueName unique name 
	 * @return name space
	 */
	public abstract NameSpace getNameSpace(Name uniqueName);

	/**
	 * Gets an iteration of name spaces in the model.
	 * 
	 * @return collections of namespaces
	 */
	public abstract Iterator<NameSpace> getNameSpaces();

	/**
	 * Gets the collections of classes in the model.
	 * 
	 * @return collection of classes
	 */
	public abstract Collection<ClassDef> getClassDef();
	
	/**
	 * Gets the class by unique name.
	 * 
	 * @param uniqueName unique name
	 * @return class
	 * @since JavaMoon-2.0.2
	 */
	public abstract ClassDef getClassDef(Name uniqueName);

	/**
	 * Gets the collection of types in the model.
	 * 
	 * @return collection of types
	 */
	public abstract Collection<Type> getTypes();
	
	/**
	 * Resets the state of the model, erasing of its content.
	 *
	 */
	public abstract void reset();
	
	
	/**
	 * Gets an abstract factory for creating new objects.
	 * 
	 * @return abstract factory
	 * @since Moon-2.1.0
	 */
	public abstract MoonFactory getMoonFactory();
	
	/**
	 * Gets the classes with source available.
	 * 
	 * @return classes with source code available  
	 */
	public abstract Collection<ClassDef> getClassDefSourceAvailable();
	
	/**
	 * Gets the universal object.
	 * 
	 * @return universal object
	 * @since Moon-2.2.1
	 */
	public abstract ClassDef getUniversalObject();
	
	/**
	 * Gets time stamp since last change.
	 * 
	 * @return timestamp
	 * @since MOON-2.4.1
	 */
	public long getTimeStamp();
	
	/**
	 * Updates current time stamp.
	 */
	public abstract void updateTimeStamp();
	
}